<template>
  <div class="echarts" style="width: 600px; height: 300px">
    <div id="mai" style="width: 600px; height: 300px"></div>
  </div>
</template>

<script>
export default {
  methods: {
    myEcharts() {
      var myChart = this.$echarts.init(document.getElementById("mai"));
      //   配置图表
      var option = {
        toolbox: {
          show: true,
          feature: {
            saveAsImage: {},
          },
        },
        title: {
          text: "库存占比图",
          left: "left",
        },
        legend: {
          orient: "vertical",
          type:"scroll",
          right: "right",
          top:"10%"
        },
        tooltip: {},
        series: [
          {
            name: "库存量",
            type: "pie",
            data: [
              { value: 1048, name: "Search Engine" },
              { value: 735, name: "Direct" },
              { value: 580, name: "Email" },
              { value: 484, name: "Union Ads" },
              { value: 300, name: "Video Ads" },
            ],
            radius: "45%",
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      };
      myChart.setOption(option);
    },
  },
  mounted() {
    this.myEcharts();
  },
};
</script>

<style scoped>
</style>